package com.lingnan.tijian.controller;

import com.lingnan.tijian.domain.Hospital;
import com.lingnan.tijian.domain.result.Result;
import com.lingnan.tijian.service.IHospitalService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/hospital")
@Slf4j
public class HospitalController
{
    @Autowired
    private IHospitalService hospitalService;

    @GetMapping("/list")
    public Result<List<Hospital>> selectHospitalList(){
        List<Hospital> list = hospitalService.list();
        return Result.success(list);
    }

    @GetMapping("/{id}")
    public Result<Hospital> selectHospitalById(@PathVariable Long id){
        log.info("医院编号:{}",id);
        Hospital hospital = hospitalService.getById(id);
        return Result.success(hospital);
    }
}
